#include "stdafx.h"
#include "Log.h"

char* Log::logFile;

void Log::Debug(const char* fmt,...){

	if (!logFile){
		TCHAR exeFullPath[MAX_PATH];
		GetModuleFileName(NULL, exeFullPath, MAX_PATH);
		(_tcsrchr(exeFullPath, _T('\\')))[1] = 0;

		char logFullPath[MAX_PATH] = { 0 };

		sprintf(logFullPath, "%s\\log.txt", exeFullPath);
		logFile = strdup(logFullPath);
	}

	va_list st;
	va_start(st, fmt);
	char  buffer[500] = { 0 };
	vsprintf(buffer, fmt, st);
	va_end(st);

	FILE* fp = fopen(logFile, "a+");
	if (fp != NULL){ 
		fprintf(fp, "[verystreamSrv] %s\n", buffer);
		fclose(fp); 
	}
}
